Skip to content

Conversation

@uditagarwal97
Copy link
Contributor

@uditagarwal97 uditagarwal97 commented Dec 20, 2025

Problem
When a kernel library deregisters with the SYCL RT, we clear the associated device images and kernel/program entries from in-memory cache. When a library deregisters with the SYCL RT parallelly after early shutdown, releasing kernel/programs might segfault because we have already released all the context (urContextRelease) during early shutdown.

Solution
Clear up in-memory cache in early shutdown before releasing SYCL contexts.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a segmentation fault that occurs when kernel libraries deregister with the SYCL runtime in parallel after early shutdown. The fix ensures that the in-memory cache (containing device images, kernels, and programs) is cleared before releasing SYCL contexts during early shutdown, preventing attempts to release kernel/program resources after their associated contexts have already been released.

Key Changes:

  • Clear in-memory cache during early shutdown before releasing default contexts
  • Replace exception throwing with early return when cache entries aren't found (post-shutdown scenario)
  • Update test expectations to reflect the new order of resource release operations

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
sycl/source/detail/global_handler.cpp Adds logic to reset in-memory cache for all platform default contexts before releasing them during early shutdown
sycl/source/detail/kernel_program_cache.hpp Changes cache clearing to use .clear() instead of reconstructing objects, and replaces exception with early return for missing cache entries
sycl/test-e2e/Scheduler/ReleaseResourcesTest.cpp Updates test expectations to reflect that programs/kernels are now released before contexts
sycl/test-e2e/KernelAndProgram/disable-caching.cpp Updates test expectations to reflect new release ordering during early shutdown
sycl/test-e2e/Basic/queue/release.cpp Updates test expectations to reflect that kernels/programs are now released before contexts

@github-actions
Copy link
Contributor

@intel/llvm-gatekeepers please consider merging

@uditagarwal97 uditagarwal97 merged commit 800bfb2 into sycl Dec 22, 2025
64 of 67 checks passed
@uditagarwal97 uditagarwal97 deleted the private/udit/clear_cache_shutdown_2 branch December 22, 2025 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants